<?php
$name=$_POST['username'];
$message=$_POST['message'];
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'root'; 
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(!$conn){
    die('连接失败: ' . mysqli_error($conn));
}
mysqli_query($conn, "set names utf8");
mysqli_select_db($conn, 'liuyanku');
$sql = "INSERT INTO message (nausername, message) VALUES ('$name', '$message')";
if(mysqli_query($conn, $sql)){
    echo '留言保存成功！';
} else{
    echo '插入数据时出错：' . mysqli_error($conn);
}?>